package com.leyou.page.controller;

import com.leyou.page.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

/**
 * @date: 2021/4/6 0006 2:30
 * @description: 处理商品详情
 */

@Controller
public class PageController {

    @Autowired
    private PageService pageService;

    @GetMapping("/item/{id}.html")
    public String pageDetail(@PathVariable("id") Long id, Model model) {

        //调用业务层获取数据
        Map<String,Object> resultMap = pageService.getDetailData(id);

        //把数据存入Model
        model.addAllAttributes(resultMap);

        //thymealeaf默认读取resources下的templates目录的文件
        return "item";
    }
}
